<?php
$where_item = "";
if (isset($_GET['var2']))
    $where_item = " where titleurl = '" . $_GET['var2'] . "' ";

$re_item = $db->select("select * from news_cat $where_item  order by orderId asc, id asc limit 1 ");
$tt_item = $db->fetch($re_item);
$tt_cat = $tt_item;
?>


<div class="left-col">
    <div class="title"><?= $co_news['titlemenu' . $hg] ?></div>
    <ul class="pl-list">
        <?php
        $re_list = $db->select("select * from news_cat order by orderId asc ");
        while ($tt_list = $db->fetch($re_list)) {
            if ($act == "news" && $tt_list['id'] == $tt_item['id'])
                $subClass = "active";
            else
                $subClass = "";
            ?>
            <li class="<?= $subClass ?>">
                <a href="<?= APPLICATION_URL ?>news/<?= $tt_list['titleurl'] ?>.html"><?= $tt_list['title' . $hg] ?></a>
                <div class="clear"></div>
            </li>		
            <?php
        }
        ?>		
    </ul>

</div>
<div class="right-col">
    <div class="title"><?= $tt_item['title' . $hg] ?></div>
    <div class="news content-text">
        <ul class="news-list">
            <?php
            $i = 0;
            include_once "library/paging.cls.php";
            $paging = new paging();
            $curpg = $_GET['var3'];
            $curpg = (isset($curpg)) ? $curpg : 1;
            $gotopage = APPLICATION_URL . "news/" . $tt_cat['titleurl'];
            $perpage = 10;
            $pagecount = 10;

            $where_list = " where idcat = '" . $tt_cat['id'] . "' ";
            $sql = "select * from news_item $where_list  ";

            $query = $db->select($sql);
            $totalrows = $db->numrows($query);
            
            $sql_list = "select * from news_item $where_list order by orderId asc, id asc limit " . (($curpg - 1) * $perpage) . ", " . $perpage;
            $qr_list = $db->select($sql_list);
            $num_list = $db->numrows($qr_list);
            if ($num_list > 0) {
                while ($tt_list = $db->fetch($qr_list)) {
                    
                    ?>
                    

                    <li>
                        <div class="thumb">
                            <a href="<?= APPLICATION_URL ?>news-detail/<?= $tt_list['titleurl'] ?>.html"><img src="<?= APPLICATION_URL ?>news-img/<?= $tt_list['image'] ?>" alt="news" /></a>
                        </div>
                        <div class="ctn">
                            <div class="tit"><a href="<?= APPLICATION_URL ?>news-detail/<?= $tt_list['titleurl'] ?>.html"><?= $tt_list['title' . $hg] ?></a></div>
                            <div class="desc">
                                <?= $tt_list['description' . $hg] ?>
                            </div>
                            <div class="more">
                                <a href="<?= APPLICATION_URL ?>news-detail/<?= $tt_list['titleurl'] ?>.html"><?php __('Xem chi tiết'); ?></a>
                            </div>
                        </div>
                        <div class="clear"></div>
                    </li>
                    <?php
                }
            }else {
                __("News not found");
            }
            ?>

        </ul>
        <div class="clear"></div>
        <div class="paging"><?php echo $paging->pagenew($totalrows, $perpage, $pagecount, $curpg, $gotopage, "", "titlepage"); ?></div>

    </div>
</div>
